
#VPATH = 

# ........ makefile
#REV=$(shell svnversion | sed 's/.*://')
REV=$(shell svnversion | sed 's/.*://' | sed 's/M//')

Target = c15_r$(REV).hex
SourceList = main.c my_macros.c SysClock.c Interrupt.c Init.c outputs.c UART.c App.c
#MicroType = 16F690
MicroType = 16F886

#CC = C:/PROGRA~1/HI-TEC~1/PICC/std/9.60/bin/picc.exe
CC = picc
CFLAGS = --pass1 -P -q --runtime=default --opt=all
def f = pipe


#ObjectList = $(patsubst %.c, %.obj, $(wildcard *.c )))
ObjectList = $(patsubst %.c, %.p1, $(SourceList)) 

b : $(Target) prog

$(Target) : $(ObjectList) 
	$(CC) $^ -O$@ -Q --chip=$(MicroType) ##-L-pSerNum=0x06B0
#	WinPic800.exe -p -s -dPIC$(MicroType) $(Target)
#	D:\PROGRA~1\Soft-Log\IcpWin\ICP_Win.exe $(Target) /p


# %.obj : %.c *.h
# 	$(CC) -C -E $< -O$@ -Zg9 -O -Q -$(MicroType)
%.p1 : %.c *.h
	$(CC) $< -O$@ -Q $(CFLAGS) "--errformat=%f: %l: (%n) %s" --chip=$(MicroType)

c: 
	rm -f rm -f *.obj *.lst *.sdb *.p1 *.pre *.hxl *.sym *.rlf *.cof *.d
	rm -f $(Target) 

e:
	etags *.c *.h

p: $(Target)
	@echo "       ======== PROGRAMMING ============"
	pk2cmd -W -V12 -PPIC$(MicroType) -E -F$(Target) -M -Y -K -I -R 
#	C:/PK2CMD/pk2cmd.exe -W -V12 -PPIC$(MicroType) -E -F$(Target) -M -Y -K -I -R 
#	C:\WinPic800\WinPic800.exe -p -s -dPIC$(MicroType) $(Target)
#	D:\PROGRA~1\Soft-Log\IcpWin\ICP_Win.exe $(Target) /p
#	pk2cmd -A5 -V12 -PPIC$(MicroType) -E -F$(Target) -M -Y -K -I


all: c b

ifeq ($(f),p)
prog: p
	echo
else
prog: 
	@echo
endif

b : $(Target) prog


# QA_WORK_VER = Z:/Development/SimPhony_V3_QA/SimPhony_Versions/Work_Version

# alld: $(Target) smd
# 	bash $(VPATH)/CreateDir.sh $(QA_WORK_VER)
# 	cp $(Target) $(QA_WORK_VER) 
# 	bash ../Utilites/h2h.sh $(BOOT_LOADER) $(Target) > $(FULL)
# 	unix2dos $(FULL)
# 	cp $(FULL) $(QA_WORK_VER) 
# 	./CLEAN.BAT

# smd:
# #	echo $(QA_WORK_VER) | email -s "Versions Update - TEST-11" dimitrip@cellnets.com,dima.development@gmail.com
# 	bash ../SimPhony_Basic/sendEMail.sh $(QA_WORK_VER)


.PHONY : c e p b prog
